<?php

namespace App\Module\Api\Controllers;
use App\Module\Api\Controllers\Request\DeleteActionRequest;
use App\Module\Api\Validator\DeleteActionValidator;
use App\System\Base\Repositories\BaseDeleteRepository;
use App\System\Base\Services\TokenService;

/**
 * 删除对像
 */
class DeleteActionController extends Controller
{
    public function __construct()
    {
        $this->query = new DeleteActionRequest();
        parent::__construct();
    }

    public function index()
    {
        (new DeleteActionValidator())->check();
        $delete = BaseDeleteRepository::getInstance();
        if($this->query->action == 1)
        {
            $user_id = TokenService::getUserId();
        }
        else
        {
            $user_id = TokenService::getMasterId();
        }
        $res = $delete->delete($this->query,$user_id);
        return apiResponse($res);
    }
}
